package com.cj.springmvc.test.task.springtemp;

import javax.jms.JMSException;
import javax.jms.ObjectMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.support.JmsUtils;
import org.springframework.stereotype.Component;

import com.cj.springmvc.test.entity.Persons;
//@Component("receiveAlert")
public class ReceiveAlert {
//	@Autowired
	private JmsTemplate jmsTemplate;
	
	public String getAlert(){
		System.out.println("准备信息接收！！！！！！！！！！！！！！！！");
		try {
		ObjectMessage receiveMessage = 
				(ObjectMessage) jmsTemplate.receive();// get messages from the default destination
		System.out.println("接收结果为null? "+ receiveMessage.getObject()==null);
			return (String) receiveMessage.getObject();
		} catch (JMSException e) {
			throw JmsUtils.convertJmsAccessException(e);
		}
	}
}
